#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN=50050;
long long a[MAXN];
int main(void){
    int n;
    int t;
    a[0]=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&t);
        a[i]=a[i-1]+t;
    }
    int q;
    scanf("%d",&q);
    int i,l;
    while(q--){
        scanf("%d%d",&i,&l);
        printf("%lld\n",a[i+l-1]-a[i-1]);
    }
}
